<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>路由简介</title>
    <script src="../../js/vue.js"></script>
</head>
<body>
<div id="app">
    {{message}}
</div>
</body>
<script>
    const NotFound = { template: '<p>Page not found</p>' }
    const Home = { template: '<p>home page</p>' }
    const About = { template: '<p>about page</p>' }
    const routes = {
        '/': Home,
        '/about': About
    };

    let app1 = new Vue({
        el: '#app',
        data: {
            message: 'hello',
            currentRoute: window.location.pathname
        },
        computed: {
            ViewComponent () {
                return routes[this.currentRoute] || NotFound
            }
        },
        render (h) {
            return h(this.ViewComponent) ;
        }
    });

</script>
</html>